package cn.school.mybatis.service;

import cn.school.mybatis.Util.MyBatisUtil;
import cn.school.mybatis.dao.StudentDao;
import cn.school.mybatis.dao.SubjectDao;
import cn.school.mybatis.pojo.Subject;
import org.apache.ibatis.session.SqlSession;

//业务逻辑bean
//服务层,调用dao方法
public class SubjectService {

    public final static SubjectService SUBJECT_SERVICE = new SubjectService();

    //查单个
    public Subject get(int id) {
        SqlSession session = MyBatisUtil.getSqlSession();
        try {
            SubjectDao dao = session.getMapper(SubjectDao.class);
            return dao.get(id);
        } finally {
            MyBatisUtil.close(session);
        }
    }



}
